import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/component.dart';

import 'index.dart';
import 'widgets/widgets.dart';

///企业列表
class ComListPage extends GetView<ComListController> {
  const ComListPage({Key? key}) : super(key: key);

  // 内容页
  Widget _buildView() {
    return ListView.separated(
        itemBuilder: (ctx, index) {
          var _item = controller.state.list![index];
          return ComListCell(mod: _item);
        },
        separatorBuilder: (ctx, index) {
          return SizedBox(
            height: 10.r,
          );
        },
        padding: EdgeInsets.only(top: 10.r),
        itemCount: controller.state.list?.length ?? 0);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ComListController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(
            context,
            title: '企业列表',
            bottom: PreferredSize(
              child: const ComListTabBar(),
              preferredSize: Size.fromHeight(44.r),
            ),
          ),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
